﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using AP.BETEL.Commons;
using Microsoft.Practices.CompositeWeb.Web.UI;
using PA.BETEL.Shell.MasterPages;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using AjaxControlToolkit;

/// <summary>
/// Summary description for WebUtil
/// </summary>
public class WebUtil
{
	public WebUtil()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public static void MostrarMensaje(string titulo, string mensaje)
    {
        HttpContext context = HttpContext.Current;
        Page currentPage = (Page)HttpContext.Current.Handler;
        IDefaultMasterView master = (IDefaultMasterView)currentPage.Master;
        master.MostrarMensaje(titulo, mensaje);
    }

    public static void ChangeControlState(System.Web.UI.Control control, bool enable)
    {
        if (control.HasControls())
        {
            foreach (System.Web.UI.Control childControl in control.Controls)
                ChangeControlState(childControl, enable);
        }
        else
        {
            if (control is TextBox)
                ((TextBox)control).Enabled = enable;
            else if (control is DropDownList)
                ((DropDownList)control).Enabled = enable;
            else if (control is CheckBox)
                ((CheckBox)control).Enabled = enable;
            else if (control is LinkButton)
            {
                ((LinkButton)control).Enabled = enable;
                ((LinkButton)control).Visible = enable;
            }
        }
    }

    public static void CleanControl(System.Web.UI.Control control)
    {
        if (control.HasControls())
        {
            foreach (System.Web.UI.Control childControl in control.Controls)
                CleanControl(childControl);
        }
        else
        {
            if (control is TextBox)
                ((TextBox)control).Text = "";
            else if (control is DropDownList)
                ((DropDownList)control).SelectedValue = Constanst.CODIGO_NEGATIVO.ToString();
            else if (control is CheckBox)
                ((CheckBox)control).Checked = false;
            else if (control is LinkButton)
            {
                ((LinkButton)control).Enabled = true;
                ((LinkButton)control).Visible = true;
            }
        }
    }

}